This document covers issues related to embedding NewtonScript syntax in HTML:
quoting for &, <, >, "; unicode; comments.
A new section covers embedding HTML in NewtonScript.
A more advanced document (available to registered users) covers:
- Adding META Slots and Values: book slots, special slots/methods, precedence.
- URL interpretation/shadowing (this permits the same HTML file to have one
behavior in a desktop version and another behavior on the Newton):
- IMG SRC: string, expressions, soupName/objName
- A HREF: string, method, appSymbol, mailto:, http:, isbn#name
- FORM ACTION: string, method, Notes, mailto: soupName
- Newt's Cape API
- eventually it may contain more introductory/tutorial information; currently
it assumes at least some NewtonScript experience (via NTK or Newt Development
Environment).
NewtonScript source for expressions and methods is processed normally as HTML
before being compiled on your Newton. You need to do a few things differently because of
HTML (delimiters) so that your embedded
NewtonScript source is converted as you intended. (Use how the example appears
in your browser rather than the underlying HTML source since that has extra quoting):
- use < for < (less than (or equal) test), e.g.,
- HTML: x < y, 3<=foo
- NewtonScript: x < y, 3<=foo
- use > for > (greater than (or equal) test), e.g.,
- HTML: x > y, 3>=bar
- NewtonScript: x > y, 3>=foo
- use " for " (quote strings), e.g.,
- HTML: "this is a string with \" an embedded quote"
- NewtonScript: "this is a string with \" an embedded quote"
- use & for & (concatenate strings), e.g.,
- HTML: "abc" & "def"
- NewtonScript: "abc" & "def"
- result: "abcdef"
- use && for && (concat strings with extra space), e.g.,
- HTML: "hello" && "world"
- NewtonScript: "hello" && "world"
- result: "hello world"
- use entity names or unicode sequences (\u) for special characters, e.g.,
- HTML(entities): "¿Quíen es?"
- NewtonScript(unicode): "\u00BF\uQu\u00ED\uen es?"
- result: "¿Quíen es?"
- inside PRE, spaces, tabs, and newline characters are preserved;
otherwise inside strings, use \t for tab, \n for newline (don't use extra spaces?)
- inside PRE or at the end of an expression, you can use // to comment out
rest of line; otherwise, delimit comments with /* ... */ (since returns are
removed, your code is really only one line, so first occurrence of //
comments out the rest of your code!).
- inside META CONTENT, if a subsequent line does not begin with whitespace,
make sure that the previous line has a delimiter -- otherwise (since returns are removed),
NewtonScript syntax errors may result.
HTML in NewtonScript
HTML can be embedded inside a NewtonScript string. This can be useful when using
Newt's Cape via its API from NTK Inspector or another application (e.g., HelpURL example).
There are two situations where you need to be careful with HTML in strings:
- to include a " (doublequote) character, either precede it with \ (backslash) or
use the character entity ". For example, "...a NewtonScript \"string\"..."
- to include a \ (backslash) character (or sequence such as \n, \t, \u),
precede it with another \. For example, "...here is a backslash \\..."
This document (in all its formats) is © 1995-98.
Steve Weyer, Greg Simon. All Rights Reserved Worldwide
Version 1.5. Last updated: Jan 1998
Steve Weyer - weyer@kagi.com
Greg Simon - gsimon@ricochet.net